package com.training.admin.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.training.admin.entity.course.Course;
/**
 * 
 * @author sjh
 *
 */
@Dao("hibernate")
public interface CourseDao {
	
	/**
	 * 
	 * @param code
	 * @return
	 */
	@Query("FROM Course WHERE disabled = false AND code =:code")
	public Course loadByCode(@Variable("code") String code);
	
	/**
	 * 
	 * @param name
	 * @return
	 */
	@Query("FROM Course WHERE disabled = false AND name =:name")
	public Course loadByName(@Variable("name") String name);

	/**
	 * list by trainer
	 * @param trainerId
	 * @return
	 */
	@Query("FROM Course WHERE disabled = false AND trainer.id =:trainerId")
	public List<Course> listByTrainer(@Variable("trainerId") Long trainerId);

}
